package actions;

import java.sql.SQLException;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.RowSet;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import db.DbException;
import forms.StudentForm;
import model.CountriesModel;
import model.UserModel;

public class StudentResidenceAction extends Action {

	private static final boolean DEBUG = true;
	//private static final int UNKNOWN = -1;
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws DbException {
	
		// get student name from form
		StudentForm sform = (StudentForm)form;
		String residence = sform.getResidence();
		
		if (DEBUG) {
			System.err.println("StudentResidenceAction: saving residence(" + residence +")");
		}
		
		// save student name into session
		if (residence != null)
			request.getSession().setAttribute("residence", residence);
		
		// store StudentForm into session
		sform = (StudentForm)request.getSession().getAttribute("sform");
		
		sform.setResidence(residence);
		
		return mapping.findForward("success");
	}
	
}
